
// Copyright (C) 2007 Richard Uhler
// This file is part of Esiply.
//
// Esiply is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, Version 2,
// as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

#ifndef _ESNI_H_
#define _ESNI_H_

typedef void* esni_value_t;
typedef void* esni_context_t;
typedef esni_value_t(*esni_function_t)(esni_context_t);
struct esni_interface_t
{
    esni_value_t (*make_number)(esni_context_t context, double value);
    esni_value_t (*make_string)(esni_context_t context, const char* value);
    esni_value_t (*make_boolean)(esni_context_t context, int value);
    esni_value_t (*make_function)(esni_context_t context,
        esni_function_t function, const char* params);
    double (*get_number)(esni_context_t context, esni_value_t value);
    int (*get_boolean)(esni_context_t context, esni_value_t value);
    const char* (*get_string)(esni_context_t context, esni_value_t value);
    esni_value_t (*evaluate)(esni_context_t context, const char* program,
        esni_value_t* arg1, esni_value_t* arg2);
    esni_value_t (*run_file)(esni_context_t context, const char* filename);

    // Create a javascript interpreter and return an esni_context_t.
    // libdir specifies the directory of where to find the library
    // files. If NULL, it uses the install directory ${datadir}/esiply/lib
    esni_context_t (*create)(const char* libdir);
};

esni_interface_t* esni_get_interface();

#endif//_ESNI_H_

